import com.wzy.YourFactory;
import com.wzy.YourRunable;

public class YourFactoryTest {

    public static void main(String[] args) {

        //饿汉模式可以解决多线程安全问题，但是不具备延迟加载的特性
        YourRunable yr = new YourRunable();
        Thread cx = new Thread(yr);
        cx.setName("查询");

        Thread xz = new Thread(yr);
        xz.setName("新增");

        cx.start();
        xz.start();


//        System.out.println(Thread.currentThread().getName());
        //多次调用MyFactory.getInstance();只会创建一个factory实例
        YourFactory factory = YourFactory.getInstance();
        factory = YourFactory.getInstance();
        factory = YourFactory.getInstance();
        factory = YourFactory.getInstance();
    }
}
